package routers

import (
	"energy-amiot-platform/api/app"
	"energy-amiot-platform/api/captcha"
	"energy-amiot-platform/api/command"
	"energy-amiot-platform/api/company"
	"energy-amiot-platform/api/device"
	"energy-amiot-platform/api/devicedata"
	"energy-amiot-platform/api/health"
	"energy-amiot-platform/api/mqttsender"
	"energy-amiot-platform/api/objectmodel"
	"energy-amiot-platform/api/product"
	"net/http"

	"github.com/gin-gonic/gin"
)

type Option func(engine *gin.Engine)

var options []Option

// include 注册app的路由配置
func include(opts ...Option) {
	options = append(options, opts...)
}

// bind 初始化
func bind(eg *gin.Engine) {
	for _, opt := range options {
		opt(eg)
	}
}

func UseRouters(r *gin.Engine) {
	r.GET("/", func(c *gin.Context) {
		c.String(http.StatusOK, "Welcome Gin Server")
	})

	include(
		company.Routers,
		product.Routers,
		objectmodel.Routers,
		device.Routers,
		command.Routers,
		app.Routers,
		mqttsender.Routers,
		health.Routers,
		devicedata.Routers,
		captcha.Routers,
	)
	bind(r)
}
